package com.biubiushop.Socket.TcpAndUdp;

import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author chenjia
 * @date 2019/7/16
 **/
public class SocketServer {

    public static void main(String[] args) throws Exception {
        ServerSocket serverSocket = new ServerSocket(9999);

        int count = 0;
        System.out.println("============服务端即将启用===========");
        Socket socket = null;
        while (true){
            socket = serverSocket.accept();

            SocketThread socketThread = new SocketThread(socket);
            socketThread.start();
            count++;
            System.out.println("客户端的数量:"+count);

            InetAddress inetAddress = socket.getInetAddress();
            String ip = inetAddress.getHostAddress();
            System.out.println(ip);
        }
    }
}
